package com.sixbro.api.docs.api;

import com.sixbro.api.docs.model.User;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.enums.Explode;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.enums.ParameterStyle;
import io.swagger.v3.oas.annotations.headers.Header;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * <p>
 *
 * </p>
 *
 * @Author: Mr.Lu
 * @Since: 2022/1/6 14:28
 */
@javax.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]")

@Tag(name = "用户模块", description = "用户管理")
public interface UserApi {
    default UserApiDelegate getDelegate() {
        return new UserApiDelegate() {
        };
    }

    @Operation(summary = "Create user", description = "This can only be done by the logged in user.", tags = { "user" })
    @ApiResponses(value = { @ApiResponse(description = "successful operation", content = { @Content(mediaType = "application/json", schema = @Schema(implementation = User.class)), @Content(mediaType = "application/xml", schema = @Schema(implementation = User.class)) }) })
    @PostMapping(value = "/user", consumes = { "application/json", "application/xml", "application/x-www-form-urlencoded" })
    default ResponseEntity<Void> createUser(
            @Parameter(description = "Created user object") @Valid @RequestBody User user) {
        return getDelegate().createUser(user);
    }

    @Operation(summary = "Creates list of users with given input array", tags = { "user" })
    @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation") })

    @PostMapping(value = "/user/createWithArray", consumes = { "application/json" })
    default ResponseEntity<Void> createUsersWithArrayInput(
            @Parameter(description = "List of user object", required = true) @Valid @RequestBody List<User> user) {
        return getDelegate().createUsersWithArrayInput(user);
    }

    @Operation(summary = "Creates list of users with given input array", description = "Creates list of users with given input array", tags = { "user" })
    @ApiResponses(value = {
            @ApiResponse(responseCode = "200", description = "Successful operation", content = { @Content(mediaType = "application/json", schema = @Schema(implementation = User.class)), @Content(mediaType = "application/xml", schema = @Schema(implementation = User.class)) }),
            @ApiResponse(description = "successful operation")

    })
    @PostMapping(value = "/user/createWithList", consumes = { "application/json" })
    default ResponseEntity<Void> createUsersWithListInput(
            @Parameter @Valid @RequestBody List<User> user) {
        return getDelegate().createUsersWithListInput(user);
    }

    @Operation(summary = "Delete user", description = "This can only be done by the logged in user.", tags = { "user" })
    @ApiResponses(value = {
            @ApiResponse(responseCode = "400", description = "Invalid username supplied"),
            @ApiResponse(responseCode = "404", description = "User not found")
    })
    @DeleteMapping(value = "/user/{username}")
    default ResponseEntity<Void> deleteUser(
            @Parameter(description = "The name that needs to be deleted", required = true) @PathVariable("username") String username) {
        return getDelegate().deleteUser(username);
    }

    @Operation(summary = "Get user by user name", tags = { "user" })
    @ApiResponses(value = {
            @ApiResponse(responseCode = "200", description = "successful operation", content = { @Content(mediaType = "application/json", schema = @Schema(implementation = User.class)), @Content(mediaType = "application/xml", schema = @Schema(implementation = User.class)) }),
            @ApiResponse(responseCode = "400", description = "Invalid username supplied", content = @Content),
            @ApiResponse(responseCode = "404", description = "User not found", content = @Content) })

    @GetMapping(value = "/user/{username}")
    default ResponseEntity<User> getUserByName(
            @Parameter(description = "The name that needs to be fetched. Use user1 for testing. ", required = true) @PathVariable("username") String username) {
        return getDelegate().getUserByName(username);
    }

    @Operation(summary = "Logs user into the system", tags = { "user" })
    @ApiResponses(value = {
            @ApiResponse(responseCode = "200", headers = {
                    @Header(name = "X-Rate-Limit", description = "calls per hour allowed by the user", schema = @Schema(type = "integer", format = "int32")),
                    @Header(name = "X-Expires-After", description = "date in UTC when toekn expires", schema = @Schema(type = "string", format = "date-time")) },
                    description = "successful operation", content = @Content(schema = @Schema(implementation = String.class))),
            @ApiResponse(responseCode = "400", description = "Invalid username/password supplied", content = @Content) })
    @GetMapping(value = "/user/login", produces = { "application/xml", "application/json" })
    default ResponseEntity<String> loginUser(
            @NotNull @Parameter(description = "The user name for login", required = false) @Valid @RequestParam(value = "username", required = false) String username,
            @NotNull @Parameter(description = "The password for login in clear text", required = false) @Valid @RequestParam(value = "password", required = false) String password) {
        return getDelegate().loginUser(username, password);
    }

    @Operation(summary = "Logs out current logged in user session", tags = { "user" })
    @ApiResponses(value = { @ApiResponse(description = "successful operation") })
    @GetMapping(value = "/user/logout")
    default ResponseEntity<Void> logoutUser() {
        return getDelegate().logoutUser();
    }

    @Operation(summary = "Update user", description = "This can only be done by the logged in user.", tags = { "user" })
    @ApiResponses(value = @ApiResponse(description = "successful operation"))
    @PutMapping(value = "/user/{username}", consumes = { "application/json", "application/xml", "application/x-www-form-urlencoded" })
    default ResponseEntity<Void> updateUser(
            @Parameter(description = "name that need to be deleted", required = true, explode = Explode.FALSE, in = ParameterIn.PATH, name = "username", style = ParameterStyle.SIMPLE, schema = @Schema(type = "string")) @PathVariable("username") String username,
            @Parameter(description = "Update an existent user in the store") @Valid @RequestBody User user) {
        return getDelegate().updateUser(username, user);
    }

    @Operation(summary = "创建用户",description = "根据姓名创建用户")
    @Parameters({
            @Parameter(name = "name", description = "名字", required = true)
    })
    @PostMapping("/create")
    default ResponseEntity<String> create(String name){
        return ResponseEntity.ok(name);
    }

    @Operation(summary = "创建用户",description = "根据姓名创建用户")
    @PutMapping("/update")
    default ResponseEntity<String> update(@Parameter(name = "name", description = "名字") String name){
        return ResponseEntity.ok(name);
    }

    @Operation(summary = "创建用户",description = "根据姓名创建用户")
    @PostMapping("/create/one")
    default ResponseEntity<User> createOne(@RequestBody User user){
        return ResponseEntity.ok(user);
    }

    @Operation(summary = "创建用户",description = "根据姓名创建用户")
    @PostMapping("/create/two")
    default ResponseEntity<User> createOne1(User user){
        return ResponseEntity.ok(user);
    }
}
